//
//  CRMessageCellFactory.m
//  TestPrj
//
//  Created by 朱铅峰 on 2020/9/28.
//  Copyright © 2020 Xing. All rights reserved.
//

#import "CRMessageCellFactory.h"
#import "CRKit.h"

@implementation CRMessageCellFactory

- (instancetype)init
{
    self = [super init];
    if (self) {
    }
    return self;
}

- (CRMessageCell *)cellInTable:(UITableView*)tableView
                 forMessageMode:(CRMessageModel *)model
{
    id<CRCellLayoutConfig> layoutConfig = [[CRKit sharedKit] layoutConfig];
    NSString *identity = [layoutConfig cellContent:model];
    CRMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:identity];
    return (CRMessageCell *)cell;
}

- (CRSessionTimestampCell *)cellInTable:(UITableView *)tableView
                            forTimeModel:(CRTimestampModel *)model
{
    NSString *identity = @"time";
    CRSessionTimestampCell *cell = [tableView dequeueReusableCellWithIdentifier:identity];
    if (!cell) {
        NSString *clz = @"CRSessionTimestampCell";
        [tableView registerClass:NSClassFromString(clz) forCellReuseIdentifier:identity];
        cell = [tableView dequeueReusableCellWithIdentifier:identity];
    }
    [cell refreshData:model];
    return (CRSessionTimestampCell *)cell;
}

@end
